package com.zhubayi.mapper;

import com.zhubayi.entity.Category;
import com.zhubayi.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 祝八一
 */
@Repository
public interface CategoryMapper {
    /**
     * 查询所有
     * @return
     */
    public List<Category> queryAll();

    /**
     * 添加数据
     * @param name
     */
    @Insert("insert into wn_category(id,name) values (null,#{name})")
    public void add(@Param("name") String name);

    /**
     * 修改数据
     * @param id
     * @param name
     */
    @Update("update wn_category set name=#{name} where id=#{id}")
    public void update(@Param("id") int id, @Param("name") String name);

    /**
     * 删除数据
     * @param id
     */
    @Delete("delete from wn_category where id=#{id}")
    public void delete(@Param("id") int id);

    Category queryById(@Param("id") Integer id);

    void delById(@Param("id") Integer id);

    List<Category> queryByName(@Param("name") String name);
}
